//导入axios工具包
import instance from "@/utils/axios.js";

//1.获取所有频道列表
function getChannelList() {
  return instance({
      url: '/v1_0/channels',
      method: 'get'


    }

  )
}
//导出接口
export {
  getChannelList
}
//2.获取文章列表
function getArticleList({
  channel_id,
  timestamp
}) {
  return instance({
    url: '/v1_0/articles',
    methods: 'get',
    params: {
      with_top: 1,
      channel_id,
      timestamp

    },

  })

}
//导出接口
export {
  getArticleList
}

//3.获取文章详情
function getArticleInfo(id) {
  return instance({
    url: `/v1_0/articles/${id}`,
    method: 'get'


  })
}

//导出接口
export {
  getArticleInfo
}

//4关注用户 与 取消关注用户
//关注用户
function followingUser(id) {
  return instance({
    url: '/v1_0/user/followings',
    methods: 'post',
    data: {
      target: id
    }

  })
}

//取消用户
function unFollowingUser(id) {
  return instance({
    url: `/v1_0/user/followings/${id}`,
    method: 'delete',
  })
}
//导出接口
export {
  followingUser,
  unFollowingUser
}

//5.点赞 与 取消点赞
//点赞
function praiseUser(id) {
  return instance({
    url: '/V1_0/article/likings',
    method: 'post',
    data: {
      target: id
    }
  })
}
//不点赞
function unPraiseUser(id) {
  return instance({
    url: `/V1_0/article/likings/${id}`,
    method: 'delete',
  })
}
//导出接口
export {
  praiseUser,
  unPraiseUser
}



//6.不喜欢 与 取消不喜欢
//不喜欢
function dislikeUser(id) {
  return instance({
    url: '/v1_0/article/dislikes',
    method: 'post',
    data: {
      target: id
    }

  })
}
// 取消不喜欢
function unDislikeUser(id) {
  return instance({
    url: ` /v1_0/article/dislikes/${id}`,
    method: ' delete',
  })
}
//导出接口
export {
  dislikeUser,
  unDislikeUser

}


//7.
function getSuggestionList(q) {
  return instance({
    url: '/v1_0/suggestion',
    method: 'get',
    params: {
      q
    }
  })
}
//导出接口
export {
  getSuggestionList

}

//8.搜索接口
function getSearchList({
  page,
  per_page,
  q
}) {
  return instance({
    url: '/v1_0/search',
    method: 'get',
    params: {
      page,
      per_page,
      q
    }
  })
}
//导出接口
export {
  getSearchList

}
